<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>GraphGL - ECHARTS-GL</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes"> <!-- Fullscreen Landscape on iOS -->
        <link rel="stylesheet" href="./common.css">
    </head>
    <body>
        <div id="main"></div>
        <script src="../node_modules/echarts/dist/echarts.js"></script>
        <script src="../dist/echarts-gl.js"></script>
        <script src="lib/jquery.min.js"></script>
        <script>
            var chart = echarts.init(document.getElementById('main'), null, {
                devicePixelRatio: 1
            });

            $.getJSON('data/eurosis.json', function (graph) {
                var edges = graph.links.map(function (edge) {
                    return {
                        source: edge.source,
                        target: edge.target,
                        value: 2
                    }
                });
                var nodes = graph.nodes.map(function (node) {
                    return {
                        // x: node[0],
                        // y: node[1],
                        symbolSize: node.symbolSize * 10,
                        value: 1,
                        itemStyle: {
                            color: node.itemStyle.normal.color
                        }
                    }
                });


                chart.setOption({
                    series: [{
                        type: 'graphGL',
                        nodes: nodes,
                        edges: edges,
                        lineStyle: {
                            color: 'rgba(255,255,255,0.2)'
                        },
                        itemStyle: {
                            opacity: 1
                        },
                        forceAtlas2: {
                            steps: 10,
                            stopThreshold: 10,
                            jitterTolerence: 10,
                            edgeWeight: [0.2, 1],
                            gravity: 0,
                            edgeWeightInfluence: 1
                        }
                    }]
                });
            });

        </script>
    </body>
</html>